<template>
  <header class="header">
    <h1>todos</h1>
    <input v-model="isChecked" id="toggle-all" class="toggle-all" type="checkbox" >
    <label for="toggle-all"></label>
    <input
     @keyup.enter="addTion(name)" v-model.trim="name"
      class="new-todo"
      placeholder="输入任务名称-回车确认"
      autofocus
    />
  </header>
</template>

<script>
export default {
  data() {
    return {
      name: '',
    }
  },
 methods: {
  addTion(name) {
    // 非空检验
    if(this.name==='') return;
    this.$emit('addition', name);
    // 发布任务后清空表单
    this.name = '';
  },
 },
 props:['list'],
 computed:{
    isChecked:{
      set(val){
        this.$emit('cheked',val);
    },
      get(){
        return this.list.every(item=>item.isDone)
      }
    }   

  }
}
</script>